/*
 * Copyright 2023 LINE Corporation
 *
 * LINE Corporation licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package com.linecorp.bot.spring.boot.handler.argument;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Test;

import com.linecorp.bot.webhook.model.ImageMessageContent;
import com.linecorp.bot.webhook.model.MemberJoinedEvent;
import com.linecorp.bot.webhook.model.MessageEvent;
import com.linecorp.bot.webhook.model.TextMessageContent;

class MessageContentArgumentResolverTest {

    @Test
    void isSupported() {
        var resolver = new MessageContentArgumentResolver(TextMessageContent.class);
        assertThat(resolver.isSupported(
                new MessageEvent.Builder(
                        null,
                        null,
                        null,
                        null,
                        new TextMessageContent.Builder("aaa", "bbb", null).build()
                )
                        .build())).isTrue();
        assertThat(resolver.isSupported(
                new MessageEvent.Builder(
                        null,
                        null,
                        null,
                        null,
                        new ImageMessageContent.Builder("aaa", null, null).build()
                )
                        .build())).isFalse();
        assertThat(resolver.isSupported(
                new MemberJoinedEvent(null, null, null, null, null, null,
                        null))).isFalse();
    }

    @Test
    void resolve() {
        var resolver = new MessageContentArgumentResolver(TextMessageContent.class);
        TextMessageContent textMessageContent = new TextMessageContent.Builder("aaa", "bbb", null).build();
        assertThat(resolver.resolve(
                "AAAA", new MessageEvent.Builder(
                        null, null, null, null, textMessageContent
                ).build())).isEqualTo(textMessageContent);
    }
}
